﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HAC;

namespace MyDomainClustering
{
    class Clustering
    {
        public static Dictionary<string, float> domainSimilarityRecord = new Dictionary<string, float>();//key:domainHash1+domainHash2,value:similarity between domain1 and domain2

        public static HashSet<Element> elements = new HashSet<Element>();

        public static int Domain_Number = 0;

        public HAC.HAC hac = new HAC.HAC(new MyFusion(), new MyDistanceMetric());

        public void addNewSimilarityPair(Pair pair)
        {
            string key = "";
            if (pair.id1.CompareTo(pair.id2) < 0)
            {
                key = pair.id1 + "-" + pair.id2;
            }
            else
            {
                key = pair.id2 + "-" + pair.id1;
            }
            if (!domainSimilarityRecord.ContainsKey(key))
            {
                domainSimilarityRecord.Add(key, pair.similarity);
                hac.addElementPair(new Element(pair.id1), new Element(pair.id2));
            }
        }

        public HAC.Cluster[] doCluster(int countCluster, float Max_Distance, float ShortCutDistance, int DebugOutputInterval)
        {
            return hac.Cluster(countCluster, Max_Distance, ShortCutDistance, DebugOutputInterval);
        }
    }
}
